from django.shortcuts import render
from django.http.response import HttpResponse
from django.shortcuts import render
import json
# Create your views here.
usernames = "wangduo"
passwords = "111111"
def Login(request):
    result={}
    if request.method=="POST":
        username = request.POST.get('username')
        password = request.POST.get('password')
        if username == usernames and password ==passwords:
            return HttpResponse(username)
        else:
            return render(request,template_name="login.html")
    if request.method == "GET":
        username = request.GET.get('username')
        password = request.GET.get('password')
        data = request.GET.get('data')
        result['username'] = username
        result['password'] = password
        result['data'] = data
        result = json.dumps(result)
        return HttpResponse(result,content_type='application/json;charset=utf-8')
        # return HttpResponse(username)
    else:
        return render(request,template_name="login.html")
